package com.zjd.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.ResourceBundle;

public class RedisUtils {
    private static JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    private static JedisPool jedisPool;
    static {
        ResourceBundle bundle = ResourceBundle.getBundle("redis");
        jedisPoolConfig.setMinIdle(Integer.valueOf(bundle.getString("redis.minIdle")));
        jedisPoolConfig.setMaxWaitMillis(Integer.valueOf(bundle.getString("redis.maxWaitMillis")));
        jedisPoolConfig.setMaxTotal(Integer.valueOf(bundle.getString("redis.maxTotal")));
        jedisPool = new JedisPool(jedisPoolConfig,
                bundle.getString("redis.host"),
                Integer.parseInt(bundle.getString("redis.port")));
    }
    public static Jedis getJedis() {
        //2.取出连接对象
        return jedisPool.getResource();
    }


}
